layui.use(['Api', 'echarts', 'request'], function () {
	let echarts = layui.echarts;
    var Api = layui.Api,
        request = layui.request;

    var column3 = echarts.init(document.getElementById('column3'));

    const colorList = ["#9E87FF", '#73DDFF', '#fe9a8b', '#F56948', '#9E87FF']

    var option = {
        title: {
            text: '涉案类别',
            subtext: '概况分布',
            left: 'center'
        },
        tooltip: {
            trigger: 'item',
            formatter: '{a} <br/>{b} : {c} ({d}%)'
        },
        legend: {
            top: 'bottom',
        },
        series: [
            {
                name: '涉案类别',
                type: 'pie',
                radius: '50%',
                data: [
                    { value: 10, name: '违纪违法' },
                    { value: 20, name: '涉法涉诉' },
                    { value: 10, name: '其它' },
                ],
                emphasis: {
                    itemStyle: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                }
            }
        ]
    };

    var success = function(res){
        let data_tmp = []
        for(var i in res.data.countList){
            data_tmp.push({
                value: res.data.countList[i],
                name: res.data.nameList[i]
            })
        }
        option.series[0].data = data_tmp
        column3.setOption(option);
    }
    var params = {
        isValid: layui.data('consoleSelect').item
    }
    request.get(Api.countCaseType, params, success)

    column3.on('click', function(params){
        // console.log('params', params)
        // 0,1,2 违纪违法,涉法涉诉,其他
        var reportCaseType = params.dataIndex;
        
        // requestParams.reportState = reportStateList[params.seriesIndex]
        // console.log(JSON.stringify(requestParams))
        
        layer.open({
            content: '../../../view/excel/excel-list-home.html?type=echarts3&reportCaseType='+reportCaseType,
            skin: 'demo-class',
            title: '案件类型统计',
            area: ['95%', '95%'],
            type: 2,
            maxmin: true,
            shadeClose: true,
            end: function () {

            }
        });
    })

    window.onresize = function () {
        column3.resize();
    }
})
